home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / BSDOffscreenLib 1.0.2 / BSDOffscreenApp ƒ / main.cp < prev   
Encoding:
Text File  |  1997-08-03  |  1.7 KB  |  76 lines  |  [TEXT/CWIE]

  1. #include "BSDOffscreenLib.h"
  2. #include "BSDMenubarLib.h"
  3.  
  4. WindowPtr        window;
  5. GWorldPtr        srcPort, maskPort, offscreen, backPort;
  6. Rect            bounds, d, p, u;
  7. short            horz = 2, vert = 2;
  8.  
  9. void Init (short num) {
  10.     MaxApplZone();
  11.     
  12.     for (short x = 1; x <= num; x++) MoreMasters();
  13.     
  14.     InitGraf(&qd.thePort);
  15.     InitFonts();
  16.     InitWindows();
  17.     InitMenus();
  18.     TEInit();
  19.     InitDialogs(nil);
  20.     InitCursor();
  21.     
  22.     FlushEvents(everyEvent, 0);
  23. }
  24.  
  25. void InitPorts (void) {
  26.     SetRect(&bounds, 0, 0, 144, 144);
  27.     
  28.     window = NewCWindow(nil, &qd.screenBits.bounds, "\p", false, plainDBox, (WindowPtr)-1L, false, 0);
  29.     srcPort = CreateGWorldPict(16, bounds, GetPicture(128));
  30.     maskPort = CreateGWorldPict(1, bounds, GetPicture(129));
  31.     offscreen = CreateGWorldEmpty(16, window->portRect);
  32.     backPort = CreateGWorldEmpty(16, window->portRect);
  33.     Screen2GWorld(backPort, srcCopy + ditherCopy);
  34.     
  35.     ShowWindow(window);
  36. }
  37.  
  38. void DisposePorts (void) {
  39.     DisposeWindow(window);
  40.     DisposeGWorld(srcPort);
  41.     DisposeGWorld(maskPort);
  42.     DisposeGWorld(offscreen);
  43. }
  44.  
  45. void main (void) {
  46.     Init(3);
  47.     InitPorts();
  48.     HideMenuBar();
  49.     HideCursor();
  50.     
  51.     GWorld2GWorld(backPort, offscreen, srcCopy);
  52.     GWorld2Window(offscreen, window, srcCopy);
  53.     
  54.     d = bounds;
  55.     
  56.     while (!Button()) {
  57.         p = d;
  58.         
  59.         OffsetRect(&d, horz, vert);
  60.         
  61.         if (d.left <= -1) horz = -horz;
  62.         if (d.top <= -1) vert = -vert;
  63.         if (d.right >= (window->portRect.right + 1)) horz = -horz;
  64.         if (d.bottom >= (window->portRect.bottom + 1)) vert = -vert;
  65.         
  66.         UnionRect(&p, &d, &u);
  67.         
  68.         GWorld2GWorldRect(backPort, offscreen, u, u, srcCopy);
  69.         GWorld2GWorldMask(srcPort, maskPort, offscreen, bounds, d);
  70.         GWorld2WindowRect(offscreen, window, u, u, srcCopy);
  71.     }
  72.     
  73.     DisposePorts();
  74.     ShowMenuBar();
  75.     ShowCursor();
  76. }